﻿@using System.Reflection
@model NBlog.Web.Application.Infrastructure.LayoutModel
<!doctype html>
<html lang="en" class="no-js">
<head>
    <meta charset="utf-8">
    <!--[if IE]><![endif]-->

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>@(ViewBag.Title ?? Model.Config.Title)</title>
    <meta name="description" content="@Model.Config.MetaDescription">
    <meta name="viewport" content="width=device-width; initial-scale=1; maximum-scale=1;">

    <link href="@Url.Action("Index", "Feed")" rel="alternate" type="application/rss+xml" title="@Model.Config.Title" />

    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/smoothness/jquery-ui.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://raw.githubusercontent.com/StackExchange/pagedown/master/demo/browser/demo.css">
    <link rel="stylesheet" href="@Url.Action("Css", "Resource", new { theme = "default" })">

    <script src="@Url.Content("~/scripts/modernizr-2.8.3.js")"></script>
    @if (!string.IsNullOrWhiteSpace(Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey))
    {
        <script type="text/javascript">
            var appInsights = window.appInsights || function (config) {
                function s(config) { t[config] = function () { var i = arguments; t.queue.push(function () { t[config].apply(t, i) }) } }
                var t = { config: config }, r = document, f = window, e = "script", o = r.createElement(e), i, u;
                for (o.src = config.url || "//az416426.vo.msecnd.net/scripts/a/ai.0.js", r.getElementsByTagName(e)[0].parentNode.appendChild(o),
                    t.cookie = r.cookie, t.queue = [], i = ["Event", "Exception", "Metric", "PageView", "Trace"]; i.length;) s("track" + i.pop());
                return config.disableExceptionTracking || (i = "onerror", s("_" + i), u = f[i], f[i] = function (config, r, f, e, o) {
                    var s = u && u(config, r, f, e, o); return s !== !0 && t["_" + i](config, r, f, e, o), s }), t
            }({
                instrumentationKey: "@Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey"
            });

            window.appInsights = appInsights;
            appInsights.trackPageView();
        </script>
    }
    @if (!string.IsNullOrWhiteSpace(Model.Config.GoogleAnalyticsId))
    {
    <script>
        (function (i, s, o, g, r, a, m) {
            i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
                (i[r].q = i[r].q || []).push(arguments)
            }, i[r].l = 1 * new Date(); a = s.createElement(o),
            m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
        })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
        ga('create', '@Model.Config.GoogleAnalyticsId', 'auto');
        ga('require', 'linkid', 'linkid.js');
        ga('require', 'displayfeatures');
        ga('send', 'pageview');
    </script>
    }
</head>
<!--[if lt IE 7 ]> <body class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <body class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <body class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <body class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<body>
    <!--<![endif]-->

    <div id="container" class="container">
        <header>
            <div id="site">
                <a href="@Url.Action("Index", "Home")">
                    <div id="site-name">
                        @Model.Config.Heading
                    </div>
                    <div id="tag-line">@Model.Config.Tagline</div>
                </a>
            </div>

            <div id="topbar">
                <div id="links" class="text-links">
                    @(Model.User.IsAuthenticated ? Html.Safe("<strong>" + Model.User.FriendlyName + "</strong> |") : Html.Blank())
                    @TwitterLink(@Model.Config.TwitterUsername)
                    @(Model.User.IsAuthenticated ? Html.ActionLink("Sign Out", "Logout", "Authentication") : Html.ActionLink("Sign In", "Login", "Authentication")) |
                    @Html.ActionLink("RSS", "Index", "Feed") |
                    @Html.ActionLink("Contact", "Index", "Contact") |
                    @Html.ActionLink("About", "Index", "About")
                </div>
                <div id="search">
                    <form action="@Url.Action("Index", "Search")">
                        <input type="text" class="box" name="q" />
                    </form>
                </div>
            </div>
        </header>

        <div id="main">
            <div class="crossbar text-links">
                @if (IsSectionDefined("Crossbar"))
                {
                    @RenderSection("Crossbar", required: false)
                }
                else
                {
                    @Html.Safe(Model.Config.Crossbar)
                }
            </div>
            @RenderBody()
        </div>

        <footer class="text-links">
            Powered by <a href="https://github.com/ChrisFulstow/NBlog">NBlog</a>
        </footer>
    </div>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script>    !window.jQuery && document.write('<script src="/scripts/jquery-1.8.0.min.js"><\/script>')</script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
    <script src="https://raw.githubusercontent.com/StackExchange/pagedown/master/Markdown.Converter.js"></script>
    <script src="https://raw.githubusercontent.com/StackExchange/pagedown/master/Markdown.Sanitizer.js"></script>
    <script src="https://raw.githubusercontent.com/StackExchange/pagedown/master/Markdown.Editor.js"></script>
    <script src="@Url.Action("JavaScript", "Resource")"></script>

    <script>
        $(function () {
            $.datepicker.setDefaults({
                dateFormat: 'dd M yy',
                changeMonth: true,
                changeYear: true,
                constrainInput: true,
                currentText: 'Today',
                showAnim: 'slide',
                showButtonPanel: true

            });
            $("#search .box").watermark("Search");
            $("input:submit, input:button, a.button, button").button();
            var a = $("pre:has(code)").addClass("prettyprint");
        });
    </script>

    @RenderSection("Scripts", required: false)

    <!--[if lt IE 7 ]>
    <script src="/scripts/js/dd_belatedpng.js?v=1"></script>
    <![endif]-->
    @*<script src="/scripts/profiling/yahoo-profiling.min.js?v=1"></script>
        <script src="/scripts/profiling/config.js?v=1"></script>*@
</body>
</html>

@helper TwitterLink(string twitterUsername) {
    if (!string.IsNullOrWhiteSpace(twitterUsername))
    {
        <a href="http://twitter.com/@twitterUsername" target="_blank">Twitter</a> <text>|</text>
    }
}
